import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MakeupServiceOrderApi } from '#/api/wedding/makeupserviceorder';

import { z } from '#/adapter/form';
import {
    DICT_Wedding_TYPE,
    getDictOptions,
    getRangePickerDefaultProps,
} from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'orderId',
      label: '订单号',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入订单号',
      },
    },
    {
      fieldName: 'artistCode',
      label: '化妆师编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入化妆师编码',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'serviceTime',
      label: '服务时间',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'serviceAddress',
      label: '服务地址',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务地址',
      },
    },
    {
      fieldName: 'serviceAmount',
      label: '服务金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务金额',
      },
    },
    {
      fieldName: 'paidAmount',
      label: '已支付金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入已支付金额',
      },
    },
    {
      fieldName: 'rating',
      label: '评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入评分',
      },
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入备注',
      },
    },
    {
      fieldName: 'status',
      label: '订单状态',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'orderId',
      label: '订单号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入订单号',
      },
    },
    {
      fieldName: 'artistCode',
      label: '化妆师编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入化妆师编码',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'serviceTime',
      label: '服务时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'serviceAddress',
      label: '服务地址',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务地址',
      },
    },
    {
      fieldName: 'serviceAmount',
      label: '服务金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务金额',
      },
    },
    {
      fieldName: 'paidAmount',
      label: '已支付金额',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入已支付金额',
      },
    },
    {
      fieldName: 'rating',
      label: '评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入评分',
      },
    },
    {
      fieldName: 'remark',
      label: '备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入备注',
      },
    },
    {
      fieldName: 'status',
      label: '订单状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_Wedding_TYPE.HandCardTypeStatus.toUpperCase(), 'string'),
        placeholder: '请选择订单状态',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<MakeupServiceOrderApi.MakeupServiceOrder>['columns'] {
  return [
    {
      field: 'id',
      title: '',
      minWidth: 120,

    },
    {
      field: 'orderId',
      title: '订单号',
      minWidth: 120,

    },
    {
      field: 'artistCode',
      title: '化妆师编码',
      minWidth: 120,

    },
    {
      field: 'customerId',
      title: '客户ID',
      minWidth: 120,

    },
    {
      field: 'serviceTime',
      title: '服务时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'serviceAddress',
      title: '服务地址',
      minWidth: 120,

    },
    {
      field: 'serviceAmount',
      title: '服务金额',
      minWidth: 120,

    },
    {
      field: 'paidAmount',
      title: '已支付金额',
      minWidth: 120,

    },
    {
      field: 'rating',
      title: '评分',
      minWidth: 120,

    },
    {
      field: 'remark',
      title: '备注',
      minWidth: 120,

    },
    {
      field: 'status',
      title: '订单状态',
      minWidth: 120,

    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}

